home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
DDJ0192.ARJ
/
RISC.ASC
< prev
next >
Wrap
Text File
|
1991-11-21
|
3KB
|
144 lines
_PROGRAMMING THE 29050_
by David L. Moore
Example 1:
(a)
[1] add gr96,gr97,gr98
[2] add gr97,gr97,1
[3] subr gr99,gr97,2
(b)
[1] load 0,0,gr96,gr97
[2] store 0,0,gr96,gr98
(c)
[1] load 0,0,gr96,gr97 ;load full 32 bit word
[2] load 0,0x01,gr96,gr97 ;load byte, zero fill
[3] load 0,0x11,gr96,gr97 ;load byte, sign extend
[4] load 0,0x02,gr96,gr97 ;load half word, zero fill
[5] load 0,0x12,gr96,gr97 ;load half word, sign extended
Example 2:
(a)
[1] xor ax,ax
[2] mov cx,100
[3] lea bx,array
[4] addloop:add ax,word ptr [bx]
[5] add bx,2
[6] loop addloop
(b)
[1a] .reg counter,gr96
[1b] .reg addr,gr97
[1c] .reg sum,gr98
[1d] .reg temp,gr99
[2] const sum,0
[3] const counter,100-2
[4] const addr,array
[5] consth addr,array
[6] addloop:load 0,0,temp,addr
[7] add addr,addr,4
[8] jmpfdec counter,addloop
[9] add sum,sum,temp
Example 3
[1] const gr96,0x12345678
[2] consth gr96,0x12345678
Example 4
(a)
[1] fdiv gr96,gr97,gr98
[2] convert gr96,gr96,unsigned,truncate,single,single
(b)
[1] const gr98,0x55555556
[2] consth gr98,0x55555556
[3] multmu gr96,gr97,gr98
Example 5
(a)
float Euc_Norm(float x[],int len)
{
int i;
float a=0.0;
for (i=0;i<len;i++) a+=x[i]*x[i];
}
(b)
[1] sub lr3,lr3,2 ;prepare counter for jmpfdec
[2] const gr96,0
[3] mtacc gr96,single_precision,0 ;clear acc 0
[4] loop: load 0,0,gr97,lr2
[5] add lr2,lr2,4
[7] jmpfdec lr3,loop
[8] fmac single_precision,0,gr97,gr97
[9] jmpi lr0
[10] mfacc gr96,single_precision,0 ;result from acc 0
Example 6
[1] srl lr3,lr3,2 ;divide count by 4
[2] sub lr3,lr3,2 ;prepare counter for jmpfdec
[3] const gr96,0
[4] mtacc gr96,single_precision,0 ;clear accumulators
[5] mtacc gr96,single_precision,1
[6] mtacc gr96,single_precision,2
[7] mtacc gr96,single_precision,3
[8] const gr96,3 ;operations per loop, less 1
[9] loop: mtsr CR,gr96 ;set load count special register
[10] loadm 0,0,gr97,lr2 ;load 4 words
[11] add lr2,lr2,16
[12] fmac single_precision,1,gr97,gr97
[13] fmac single_precision,2,gr98,gr98
[14] fmac single_precision,3,gr99,gr99
[15] jmpfdec lr3,loop
[16] fmac single_precision,4,gr100,gr100
[17] mfacc gr96,single_precision,0 ;combine acc values
[18] mfacc gr97,single_precision,1
[19] fadd gr96,gr96,gr97
[20] mfacc gr98,single_precision,2
[21] mfacc gr99,single_precision,3
[22] fadd gr96,gr96,gr98
[23] jmpi lr0
[24] fadd gr96,gr96,gr99